<?php
/**
* @name Maiji
* @author pd87@qq.com
* @copyright m-j.cc
* @version v1.0
*/
namespace MAIJI;

class IpAddr
{
	public function ip($ip){
		header("Content-type:text/html;charset=GBK");
		include_once(__DIR__.'/ip/IpLocation.php');
		$ipa = new \IpLocation;
		$ipadd = $ipa -> getlocation($ip);
		header("Content-type:text/html;charset=UTF-8");
		$_ls = iconv('GBK//IGNORE', 'UTF-8', $ipadd['country']);
		$ipadd['country'] = iconv('GBK//IGNORE', 'UTF-8', $ipadd['country']);
		$ipadd['area'] = iconv('GBK//IGNORE', 'UTF-8', $ipadd['area']);
		if(strpos($_ls,"省")){
			$a = substr($_ls,0,strpos($_ls,"省")+3);
			$_ls = substr($_ls,strpos($_ls,"省")+3);
			$b = substr($_ls,0,strpos($_ls,"市")+3);
			$c = substr($_ls,strpos($_ls,"市")+3);
			$ls['sheng'] = $a;
			$ls['shi'] = $b;
			$ls['qu'] = $c;
		}
		$ipadd['add'] = $ls;
		return $ipadd;
	}
}